// pages/market/market.js

const app = getApp();
Page({
  data: {
    inputShowed: false,
    inputVal: "",
    show_select_line: false,
    storeList:[],
    list:undefined,
    
  },

  onLoad: function (options) {

    app.sendGetRequest('/community/ec/category?category='+options.category, (res) => {
      console.log(res.data);
      this.setData({
        list: res.data
      })
      console.log(this.storeList);
    }, (err) => {
      console.log(err.errMsg)
    })
    
  },

  showInput: function () {
    this.setData({
        inputShowed: true
    });
  },
  hideInput: function () {
    var v_posts_list = this.data.posts_list
    this.setData({
        inputVal: "",
        inputShowed: false,
        visible_posts_list: v_posts_list
    });
  },
  clearInput: function () {
    this.setData({
        inputVal: ""
    });
  },
  inputTyping: function (e) {
      this.setData({
          inputVal: e.detail.value
      });
  },
  // 标题关键字搜索
  search: function (e){
    // 搜索字段
    var searchtext = this.data.inputVal
    var posts_list = this.data.posts_list
    var v_posts_list = []
    for(var i=0; i<posts_list.length; i++){
      var temp = posts_list[i].title.indexOf(searchtext)
      if(temp!=-1){
        v_posts_list.push(posts_list[i])
      }
    }
    this.setData({
      visible_posts_list: v_posts_list
    })
  },

  

})